package com.cqrt.util;




import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.impl.DefaultMapperFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OrikaConfig {

    @Bean
    public MapperFactory mapperFactory() {
        DefaultMapperFactory mapperFactory = new DefaultMapperFactory.Builder()
            .mapNulls(false)  // 不映射null值
            .build();
        
        // 注册全局转换器
        mapperFactory.getConverterFactory().registerConverter(
            new DateToLocalDateTimeConverter()
        );
        
        return mapperFactory;
    }
    
    @Bean
    public BeanMappers beanMappers(MapperFactory mapperFactory) {
        return new BeanMappers(mapperFactory);
    }
}